/****************************************************************************/
/* File: scs-image.cpp                                                      */
/* Desc: Implementation file for the video image type                       */
/* Created: 2014-11-20                                                      */
/* Revised: 2014-11-21                                                      */
/* Authors: Sterling P. de Mille                                            */
/****************************************************************************/

// specification file
#include "scs-image.h"

SCSimage::SCSimage (const SCSint iSizeX, const SCSint iSizeY)
{
	m_pkImage = NULL;
	Init(iSizeX, iSizeY);
}

SCSimage::SCSimage (const SCSimage& rkImage)
{
	// copy image
	m_pkImage = NULL;
}

SCSimage::~SCSimage ()
{
	if (m_pkImage) SDL_FreeSurface(m_pkImage);
	m_pkImage = NULL;
}

void SCSimage::Init (const SCSint iSizeX, const SCSint iSizeY)
{
	if (SCSdisplay::Singleton()->BitDepth() == 16) {
		m_pkImage = SDL_CreateRGBSurface(SDL_SRCALPHA | SDL_SRCCOLORKEY | SDL_HWSURFACE, iSizeX, iSizeY, 16, RED_MASK16, GREEN_MASK16, BLUE_MASK16, ALPHA_MASK16);
	} else {
		m_pkImage = SDL_CreateRGBSurface(SDL_SRCALPHA | SDL_SRCCOLORKEY | SDL_HWSURFACE, iSizeX, iSizeY, 32, RED_MASK32, GREEN_MASK32, BLUE_MASK32, ALPHA_MASK32);
	}
}

SCSint SCSimage::SizeX () const
{
	return m_pkImage->w;
}

SCSint SCSimage::SizeY () const
{
	return m_pkImage->h;
}

SCSfloat SCSimage::GetRed (const SCSint iPosX, const SCSint iPosY) const
{
	return 0;
}

SCSfloat SCSimage::GetGreen (const SCSint iPosX, const SCSint iPosY) const
{
	return 0;
}

SCSfloat SCSimage::GetBlue (const SCSint iPosX, const SCSint iPosY) const
{
	return 0;
}

SCSfloat SCSimage::GetAlpha (const SCSint iPosX, const SCSint iPosY) const
{
	return 0;
}

SCSint32u SCSimage::GetPixel (const SCSint iPosX, const SCSint iPosY) const
{
	return 0;
}

void SCSimage::SetRed (const SCSfloat fRed, const SCSint iPosX, const SCSint iPosY)
{

}

void SCSimage::SetGreen (const SCSfloat fGreen, const SCSint iPosX, const SCSint iPosY)
{

}

void SCSimage::SetBlue (const SCSfloat fBlue, const SCSint iPosX, const SCSint iPosY)
{

}

void SCSimage::SetAlpha (const SCSfloat fAlpha, const SCSint iPosX, const SCSint iPosY)
{

}

void SCSimage::SetPixel (const SCSint32u iPixel, const SCSint iPosX, const SCSint iPosY)
{

}

SCSint8u* SCSimage::Pixels ()
{
	return NULL;
}

SCSerror SCSimage::CopyImageArea (SCSimage& rkImage, SCSrectangle& rkSource, SCSrectangle& rkDestination)
{
	SDL_BlitSurface(rkImage.m_pkImage, &rkSource, m_pkImage, &rkDestination);
	return SCS_ERROR_NONE;
}

SCSerror SCSimage::SaveAsFile (const SCSstring& rsFilename)
{
	return SCS_ERROR_NONE;
}

SCSerror SCSimage::LoadFromFile (const SCSstring& rsFilename)
{
	return SCS_ERROR_NONE;
}
